package com.asha.md360player4android.vr.projection;

import android.graphics.RectF;

import com.asha.vrlib.MDVRLibrary;
import com.asha.vrlib.common.MDDirection;
import com.asha.vrlib.strategy.projection.AbsProjectionStrategy;
import com.asha.vrlib.strategy.projection.IMDProjectionFactory;
import com.asha.vrlib.strategy.projection.MultiFishEyeProjection;

/**
 * Created by hzqiujiadi on 16/8/20.
 * hzqiujiadi ashqalcn@gmail.com
 */
public class CustomProjectionFactory implements IMDProjectionFactory {

    public static final int CUSTOM_PROJECTION_FISH_EYE_RADIUS_VERTICAL = 9611;
    public static final int CUSTOM_PROJECT_CIRCLE_EXTRA = 9612;
    public static final int CUSTOM_PROJECT_DOME_PANORAMA_FBO = 9613;
    public static final int CUSTOM_PROJECT_DOME_PANORAMA_140 = 9614;
    public static final int CUSTOM_PROJECT_DOME_PANORAMA_71_5 = 9615;
    public static final int CUSTOM_PROJECT_CALIBRATE_CIRCLE = 9616;
    public static final int CUSTOM_PROJECT_CALIBRATE_DOME = 9617;

    public CustomProjectionFactory() {
    }

    @Override
    public AbsProjectionStrategy createStrategy(int mode, RectF textureSize) {
        switch (mode) {
            case CUSTOM_PROJECTION_FISH_EYE_RADIUS_VERTICAL:
                return new MultiFishEyeProjection(0.745f, MDDirection.VERTICAL);
            case CUSTOM_PROJECT_CIRCLE_EXTRA:
                return new FYCircleProjection();
            case CUSTOM_PROJECT_DOME_PANORAMA_FBO:
                return new FYDomeProjectionFBO(textureSize, 180f, true);
            case CUSTOM_PROJECT_DOME_PANORAMA_140:
                return new FYDomeProjection(textureSize, 180f, true);
            case CUSTOM_PROJECT_DOME_PANORAMA_71_5:
                return new FYDomeProjection(textureSize, 71.95f, true);
            case CUSTOM_PROJECT_CALIBRATE_CIRCLE:
                return FYCalibrateCircleProjection.create(MDVRLibrary.PROJECTION_MODE_PLANE_FIT, textureSize);
            case CUSTOM_PROJECT_CALIBRATE_DOME:
                return FYCalibrateDomeProjection.create(MDVRLibrary.PROJECTION_MODE_PLANE_FIT, textureSize, 71.95f, true);
            default:
                return null;
        }
    }
}
